import '../entities/token_entity.dart';

/// 刷新令牌响应模型
/// 
/// 对应接口: POST /api/token/refresh
/// 用于封装令牌刷新操作的响应信息
class RefreshTokenResp {
  /// 是否成功
  final bool isSuccess;
  
  /// 错误信息
  final String? errorMessage;
  
  /// 新的令牌实体
  final TokenEntity? tokenEntity;
  
  const RefreshTokenResp._({
    required this.isSuccess,
    this.errorMessage,
    this.tokenEntity,
  });
  
  /// 创建成功响应
  factory RefreshTokenResp.success(TokenEntity tokenEntity) {
    return RefreshTokenResp._(
      isSuccess: true,
      tokenEntity: tokenEntity,
    );
  }
  
  /// 创建失败响应
  factory RefreshTokenResp.failure(String errorMessage) {
    return RefreshTokenResp._(
      isSuccess: false,
      errorMessage: errorMessage,
    );
  }
  
  /// 是否失败
  bool get isFailure => !isSuccess;
  
  @override
  String toString() {
    return 'RefreshTokenResp(isSuccess: $isSuccess, errorMessage: $errorMessage, tokenEntity: $tokenEntity)';
  }
}

